<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="食材编号" prop="FITEMNO">
            <el-input v-model="dataForm.FITEMNO"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="食材分类">
              <el-select v-model="dataForm.FCATNAME" placeholder="请选择">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>


        <el-col :span="8">
            <el-form-item label="食材类型">
              <el-select v-model="dataForm.FITEMTYPE" placeholder="请选择" >
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
          <el-form-item label="食材名称"" prop="FITEMNAME">
            <el-input v-model="dataForm.FITEMNAME"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="食材规格" prop="FSPEC">
            <el-input v-model="dataForm.FSPEC"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="单位" prop="FUNIT">
            <el-input v-model="dataForm.FUNIT"   />
          </el-form-item>
        </el-col>


          <el-col :span="8">
            <el-form-item label="供应商">
              <el-select v-model="dataForm.FSUPNAME" placeholder="请选择" >
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
          <el-form-item label="保质期"" prop="FDAY">
            <el-input v-model="dataForm.FDAY"   />
          </el-form-item>
        </el-col>

        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加场地</el-button> -->
            <el-button type="primary" :loading="loading" @click="closePage">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <template>
     <el-tabs v-model="activeName" type="card" @tab-click="handleClick">

      <el-tab-pane label="食材图片" name="second">
        
        <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
          
          <el-col :span="12">
          <el-upload
            class="avatar-uploader"
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload">
            <img v-if="imageUrl1" :src="imageUrl1" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-col>

         </el-form>

      </el-tab-pane>

    </el-tabs>
    
   </template>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        imageUrl1:require('@/assets/images/me/lims070301.png'),
        activeName: 'second',

        title: "新增",
        insertorupdate: true,
        dataForm: {
            FSUPNAME: "萧山银龙农业发展有限公司",
            FITEMNO:"100002",
            FITEMNAME: "油麦菜",
            FSPEC:"500g",
            FNOTE:"",
            FCATNAME:"[VC-001-001]油麦菜",
            FITEMTYPE: "称重食材",
            FDAY:3
        },
        rules: {
          FUSERNUMBER:[
            { required: true, message: '请输入学籍号码', trigger: 'blur' },
          ],
          FUSER: [
            { required: true, message: '请输入申请人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入申请理由', trigger: 'blur' },
          ],
        },
        list1: [{ "FENTRYID":1,
                  "FTYPE": "旅游社经营许可证",
                  "FDATE":"2028-12-31",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FTYPE": "企业营业执照",
                  "FDATE":"2045-02-09",
                  "FMEMO": ""
                }],
        
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '1',
          label: '称重食材'
        }, {
          value: '2',
          label: '普通食材'
        }],

        //所属校区选择数据
        options2: [{
          value: '1',
          label: '[VC-001-007]大白菜'
        }, {
          value: '2',
          label: '[VC-001-001]油麦菜'
        }, {
          value: '3',
          label: '[VC-001-002]菠菜'
        }],

        options3: [{
          value: '1',
          label: '萧山银龙农业发展有限公司'
        }, {
          value: '2',
          label: '萧山龙商副食品批发有限公司'
        }, {
          value: '3',
          label: '杭州种子农业发展有限公司'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      closePage(){
        console.log('关闭弹窗dialog');
        this.visible = false;
      },
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shopdate(id) {
        let link = document.createElement('a');
        link.href = 'http://180.166.193.6:90/images/study/acc-01.png';
        link.target = '_blank'; // 在新窗口或新标签页中打开URL
        link.click();
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>